package com.cskaoyan.exception;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author stone
 * @date 2022/06/23 17:12
 */
//@Component
public class CustomHandlerExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        // 通过它也可以做个性化的异常处理，如果要做，需要你自己来做个性化的东西
        if (e instanceof ArithmeticException) {
            //做个性化的异常处理
            System.out.println(e.getMessage());
        }
        return new ModelAndView("/exception.jsp");
    }
}
